const db = require('../db/index');
const DataType = require('sequelize');
const User = require('./User');
/**es6继承 会员卡表*/
class Buy extends DataType.Model {}
Buy.init(
    {
        id: {
            type: DataType.INTEGER,
            allowNull: false,
            autoIncrement: true,
            primaryKey: true
        },
        userId: {
            type: DataType.INTEGER,
            comment: '用户ID',
            allowNull: false
        },
        type: {
            type: DataType.STRING,
            comment: '购买商品',
            defaultValue: 0,
            allowNull: false
        },
        price: {
            type: DataType.DECIMAL(10, 2),
            comment: '支付方式',
            defaultValue: 0,
            allowNull: false
        },
        status: {
            type: DataType.BOOLEAN,
            comment: '0删除 1正常',
            defaultValue: 1,
            allowNull: false
        }
    },
    {
        tableName: 'buy',
        modelName: 'buy',
        sequelize: db
    }
);
// Buy.sync({ force: true });
Buy.belongsTo(User['default'], { as: 'userData', foreignKey: 'userId' });
exports['default'] = Buy;
